# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html

import json
from scrapy.exceptions import DropItem
from pypinyin import lazy_pinyin

class ThreechardomainPipeline(object):
    def __init__(self):
        self.file = open('domain.txt', 'wb')

    def process_item(self, item, spider):
        line = ""
        if item['name']:
            line += item["name"].encode("utf-8")
            for x in lazy_pinyin(item['name']):
                line += x.encode('utf-8')

            line += ";\r\n"
            self.file.write(line)
            return item

        else:
            raise DropItem("Missing word ")


